package com.lbc.tree;

import java.util.ArrayList;

public class Test {
    //  以ArrayList为例，看看数组怎么扩容
    @SuppressWarnings("unused")
    public static void main(String[] args) {

        // ArrayList 维护了数组 transient Object[] elementData;
        @SuppressWarnings("rawtypes")
        ArrayList arrayList = new ArrayList();

        /**
         *   ArrayList的底层仍然是进行数组扩容
         private void grow(int minCapacity) {
         // overflow-conscious code
         int oldCapacity = elementData.length;
         int newCapacity = oldCapacity + (oldCapacity >> 1);
         if (newCapacity - minCapacity < 0)
         newCapacity = minCapacity;
         if (newCapacity - MAX_ARRAY_SIZE > 0)
         newCapacity = hugeCapacity(minCapacity);
         // minCapacity is usually close to size, so this is a win:
         elementData = Arrays.copyOf(elementData, newCapacity);
         }
         *
         */
    }
}
